package com.atguigu.gulimall.order.web;

import com.atguigu.common.vo.MemberRespVo;
import com.atguigu.gulimall.order.entity.OrderEntity;
import com.atguigu.gulimall.order.interceptor.LoginUserInterceptor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

@Controller
public class HelloController {


    @Autowired
    RabbitTemplate rabbitTemplate;

    @GetMapping("/{page}.html")
    public String listPage(@PathVariable("page") String page) {
        return page;
    }


    @ResponseBody
    @GetMapping("/test/create")
    public void create() {
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setId(1L);
        orderEntity.setOrderSn(UUID.randomUUID().toString());
        orderEntity.setReceiverName("wang");
        orderEntity.setModifyTime(new Date());
        orderEntity.setReceiverDetailAddress("hongmao lantu ");
        rabbitTemplate.convertAndSend("order-event-exchange","order.create.order",orderEntity);

    }

}